package formula.web;

import java.io.Serializable;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import formula.business.model.Level;
import formula.business.repo.LevelRepository;

@SuppressWarnings("serial")
@ManagedBean
@SessionScoped
public class LevelsHome implements Serializable {

	public static final String EL_NAME = "#{levelsHome}";
	@ManagedProperty(value = LevelRepository.EL_NAME)
	private LevelRepository levelRepository;
	//
	private List<Level> levels;

	public void clear() {
		levels = null;
	}

	public void prepare() {
		levels = levelRepository.findAll();
	}

	public List<Level> getLevels() {
		if (levels == null)
			prepare();
		return levels;
	}

	public void setLevelRepository(LevelRepository _levelRepository) {
		levelRepository = _levelRepository;
	}
}
